import moment from "moment";

export default class DateUtil {
  static formatLeftTime(leftSeconds) {
    const days = parseInt(leftSeconds / 60 / 60 / 24)
    const hour = parseInt(leftSeconds / 60 / 60 % 24)
    const minutes = parseInt(leftSeconds / 60 % 60)
    const seconds = parseInt(leftSeconds % 60)
    let result = ''
    if (days > 0) {
      result += DateUtil.w(days) + '天 '
    }
    result += `${DateUtil.w(hour)}:${DateUtil.w(minutes)}:${DateUtil.w(seconds)}`
    return result
  }

  static w(v) {
    return v < 10 ? '0' + v : v
  }

  static currentTime() {
    return moment().format('MM-DD HH:mm')
  }

  static currentDate() {
    return moment().format('YYYY-MM-DD')
  }

}
